Skip to content

Conversation

@mikekistler
Copy link
Contributor

Motivation and Context

This PR adds the ability to set fields of the _meta parameter in requests with the high-level request methods.

It also refactored these methods to move several parameters common in request methods -- JsonSerializerOptions, ProgressToken, and the new Meta field -- to an options bag to make these signatures more concise.

How Has This Been Tested?

All tests pass with the revised method signatures.

Breaking Changes

This will be breaking (as currently implemented) for users that specify any of these (uncommonly used) parameters.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Some new features in the 2025-11-25 version of the MCP spec require setting and reading fields of _meta, e.g. SEP-1686: Tasks. This change will make it easier for users to access these new features.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a RequestOptions class to consolidate common optional parameters (Meta, JsonSerializerOptions, and ProgressToken) across MCP client and server request methods. This refactoring reduces method signature complexity and enables setting the _meta field in requests, which is needed for new MCP spec features like SEP-1686 (Tasks).

Key Changes

  • Added new RequestOptions class to hold optional request parameters
  • Updated all client and server request method signatures to accept RequestOptions instead of individual parameters
  • Created PingRequestParams protocol class for structured ping requests
  • Updated tests to use the new method signatures with named parameters or null for options

Reviewed Changes

Copilot reviewed 32 out of 33 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/ModelContextProtocol.Core/RequestOptions.cs New options bag class with Meta, JsonSerializerOptions, and ProgressToken properties
src/ModelContextProtocol.Core/Protocol/PingRequestParams.cs New protocol parameter class for ping requests
src/ModelContextProtocol.Core/Client/McpClient.Methods.cs Updated all client methods to accept RequestOptions and properly set Meta in request params
src/ModelContextProtocol.Core/Server/McpServer.Methods.cs Updated SampleAsync and RequestRootsAsync to accept RequestOptions
src/ModelContextProtocol.Core/Client/McpClientExtensions.cs Updated extension methods to wrap individual parameters in RequestOptions
src/ModelContextProtocol.Core/Server/McpServerExtensions.cs Updated extension methods to forward calls with named parameters
src/ModelContextProtocol.Core/Client/McpClient*.cs Updated client wrapper classes to construct RequestOptions when calling client methods
src/ModelContextProtocol.Core/McpJsonUtilities.cs Added PingRequestParams to source generation context
tests/**/*.cs Updated all test call sites to use new signatures with null or named parameters
samples/**/*.cs Updated sample code to use named parameters for cancellationToken

@mikekistler mikekistler requested a review from halter73 November 17, 2025 22:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 34 out of 35 changed files in this pull request and generated 8 comments.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Contributor

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks close...

@stephentoub
Copy link
Contributor

#970 (comment) still needs to be addressed. Also there are conflicts that need to be resolved.

@stephentoub stephentoub merged commit c447973 into main Dec 4, 2025
11 checks passed
@stephentoub stephentoub deleted the mdk/expose-meta branch December 4, 2025 22:32
@jeffhandley jeffhandley added the breaking-change This issue or PR introduces a breaking change label Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change This issue or PR introduces a breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants